﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Http;
using System.Web.Http.Results;
using HCQ2_Common.Constant;
using HCQ2_IBLL;
using HCQ2_Model.ClassRoom;
using HCQ2_Model.ViewModel;
using HCQ2_Model.ViewModel.WebAPI;
using HCQ2WebAPI_Logic.BaseAPIController;
using HCQ2WebAPI_Logic.Filters;
using HCQ2_Model.VLine.InputDto;
using HCQ2WebAPI_Logic.Model;
using HCQ2UI_Helper.Session;

namespace HCQ2WebAPI_Logic.DocumentController
{
    /// <summary>
    /// 直播课堂相关内容
    /// 创建人：Joychen
    /// </summary>
    public class VRLineClassRoomController : BaseWeiXinApiLogic
    {
        #region 1.0 获取登录总次数 + GetLoginNum(LoginNumInputDto dto)
        /// <summary>
        /// 获取登录总次数
        /// </summary>
        /// <param name="dto">参数</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetLoginNum(LoginNumInputDto dto)
        {
            int result = operateContext.bllSession.T_User.GetLoginNum(dto);
            return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "获取登录总次数成功~", result);
        }
        #endregion

        #region 1.1 获取系统用户数 + GetSysUserNum(SysUserInputDto unitDto)
        /// <summary>
        /// 获取系统用户数
        /// </summary>
        /// <param name="unitDto">参数</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetSysUserNum(SysUserInputDto unitDto)
        {
            int result = operateContext.bllSession.T_User.GetSysUserNum(unitDto);
            return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "获取系统用户数成功~", result);
        }
        #endregion

        #region 1.2 获取系统在线人数 + GetSysLineUserNum(SysUserInputDto unitDto)
        /// <summary>
        /// 获取系统在线人数
        /// </summary>
        /// <param name="unitDto">参数</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetSysLineUserNum(SysUserInputDto unitDto)
        {
            int result = operateContext.bllSession.T_User.GetSysLineUserNum(unitDto);
            return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "获取系统在线人数成功~", result);
        }
        #endregion

        #region 1.3 获取作品数 + GetWorkNum(WorkNumInputDto unitDto)
        /// <summary>
        /// 获取作品数
        /// </summary>
        /// <param name="dto">参数</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetWorkNum(WorkNumInputDto dto)
        {
            int result = operateContext.bllSession.T_DocumentFolder.GetWorkNum(dto);
            return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "获取作品数成功~", result);
        }
        #endregion

        #region 1.4 获取目录数 + GetFolderNum(FolderNumInputDto dto)
        /// <summary>
        /// 获取目录数
        /// </summary>
        /// <param name="dto">参数</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetFolderNum(FolderNumInputDto dto)
        {
            if (!ModelState.IsValid)
                return ApiResultJsonModel.RedirectWebApi(WebResultCode.Exception, getErrorMessage(ModelState), null);
            if (!string.IsNullOrEmpty(dto.userid))
                dto.user_id = SysPermissSession.ChangeIdByGuid(dto.userid);
            int result = operateContext.bllSession.T_DocumentFolder.GetFolderNum(dto);
            return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "获取目录数成功~", result);
        }
        #endregion

        #region 1.5 获取上课人数 + GetLearnNum(LearnClassNumInputDto dto)
        /// <summary>
        /// 获取上课人数
        /// </summary>
        /// <param name="dto">参数</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetLearnNum(LearnClassNumInputDto dto)
        {
            int result = operateContext.bllSession.T_DocumentFolder.GetLearnNum(dto);
            return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "获取上课人数成功~", result);
        }
        #endregion

        #region 1.6 获取直播课堂数 + GetLinesClassNum(LearnClassNumInputDto dto)
        /// <summary>
        /// 获取直播课堂数
        /// </summary>
        /// <param name="dto">参数</param>
        /// <returns></returns>
        [HttpPost]
        [ModelValid]
        public WebApiResultJsonModel GetLinesClassNum(LearnClassNumInputDto dto)
        {
            if (!string.IsNullOrEmpty(dto.userid))
                dto.user_id = SysPermissSession.ChangeIdByGuid(dto.userid);
            int result = operateContext.bllSession.T_DocumentFolder.GetLinesClassNum(dto);
            return ApiResultJsonModel.RedirectWebApi(WebResultCode.Ok, "获取直播课堂数成功~", result);
        }
        #endregion
    }
}